import request from '@/utils/request'

export default {
  // 列表
  query(data) {
    return request({
      url: `/v1/purchase/purchase/list`,
      method: 'post',
      data
    })
  },
  // 统计
  total(data) {
    return request({
      url: `/v1/purchase/purchase/total`,
      method: 'post',
      data
    })
  },
  // 批量退回
  back(data) {
    return request({
      url: `/v1/purchase/purchase/batch-back`,
      method: 'post',
      data,
      returnData: true
    })
  },
  // 1688下单
  order(data) {
    return request({
      url: `/v1/purchase/purchase/order`,
      method: 'post',
      data
    })
  },
  // 导入物流单号
  importTrackingNo(data) {
    return request({
      url: `/v1/purchase/purchase/import-tracking-no`,
      method: 'post',
      data
    })
  },
  // 账期支付
  periodPayment(data) {
    return request({
      url: `/v1/purchase/purchase/period-payment`,
      method: 'post',
      data
    })
  },
  // 申请付款
  applyPayment(data) {
    return request({
      url: `/v1/purchase/purchase/apply-payment`,
      method: 'post',
      data
    })
  },
  // 申请退款
  applyRefund(data) {
    return request({
      url: `/v1/purchase/purchase/apply-refund`,
      method: 'post',
      data
    })
  },
  // 申请退货
  applyReturn(data) {
    return request({
      url: `/v1/purchase/return-goods/apply-return`,
      method: 'post',
      data
    })
  },
  // 获取选中的采购单信息，申请用
  selectDetail(data) {
    return request({
      url: `/v1/purchase/purchase/select-detail`,
      method: 'post',
      data
    })
  },
  // 根据采购单生成合同
  addByPurchase(data) {
    return request({
      url: `/v1/contract/contract/add-by-purchase`,
      method: 'post',
      data
    })
  },
  // 明细
  detail(params) {
    return request({
      url: `/v1/purchase/purchase/detail`,
      method: 'get',
      params
    })
  },
  // 获取合同模板option
  getTemplate(params) {
    return request({
      url: `/v1/purchase-config/contract-template/get-template-id-option`,
      method: 'get',
      params
    }).then(res => res.data)
  },
  // 物流跟踪信息
  logistics(params) {
    return request({
      url: `/v1/purchase/purchase/get-logistics`,
      method: 'get',
      params
    }).then(res => res.data)
  },
  // 手动完结
  completePurchase(data) {
    return request({
      url: `/v1/purchase/purchase/complete-purchase`,
      method: 'post',
      data,
      returnData: true
    })
  },
  // 更新备货方式
  updatePrepareType(data) {
    return request({
      url: `/v1/purchase/purchase/update-prepare-type`,
      method: 'post',
      data,
      returnData: true
    })
  },
  // 阿里账期批量付款
  periodApplyPayment(data) {
    return request({
      url: `/v1/purchase/purchase/period-apply-payment`,
      method: 'post',
      data,
      returnData: true
    })
  },
  // 调整采购人员
  updatePurchase(data) {
    return request({
      url: `/v1/purchase/purchase/update-purchase-user`,
      method: 'post',
      data,
      returnData: true
    })
  },
  // 获取1688交易方式
  getTradeType() {
    return request({
      url: `/v1/purchase/purchase/get-trade-type`,
      method: 'get',
    })
  },
  // 获取1688支付方式
  getPayType() {
    return request({
      url: `/v1/purchase/purchase/get-pay-type`,
      method: 'get',
    })
  },
  // 添加物流单号
  addTrack(data) {
    return request({
      url: `/v1/purchase/purchase/add-track-no`,
      method: 'post',
      data
    }).then(res => res.data)
  },
  // 查询快递单号
  getTrack(data) {
    return request({
      url: `/v1/purchase/purchase/get-tracking`,
      method: 'post',
      data
    }).then(res => res.data)
  },
  // 根据快递单号获取物流商
  getSupplier(data) {
    return request({
      url: `/v1/purchase/purchase/get-tracking-supplier`,
      method: 'post',
      data
    }).then(res => res.data)
  },
  // 根据快递单号获取物流商
  getLogistics(params) {
    return request({
      url: `v1/purchase-config/logistics-config/get-logistics-supplier`,
      method: 'get',
      params
    }).then(res => res.data)
  },
  //自动生成合同
  autoCreatePurchase(data) {
    return request({
      url: `/v1/contract/contract/auto-create-purchase`,
      method: 'post',
      data,
      returnData: true
    })
  },
}
